

angular.module('MyApp',['ngAnimate','ngMaterial' ])

.controller('AppCtrl',['$scope', function($scope) {
	$scope.title1 = 'Button';
	$scope.title4 = 'Warn';
	$scope.isDisabled = true;

	$scope.googleUrl = 'http://google.com';


	$scope.data = {
		group1 : 'Banana',
		group2 : '2',
		group3 : 'avatar-1'
	};

	$scope.avatarData = [{
		id: "avatars:svg-1",
		title: 'avatar 1',
		value: 'avatar-1'
	},{
		id: "avatars:svg-2",
		title: 'avatar 2',
		value: 'avatar-2'
	},{
		id: "avatars:svg-3",
		title: 'avatar 3',
		value: 'avatar-3'
	}];

	$scope.radioData = [
	{ label: '1', value: 1 },
	{ label: '2', value: 2 },
	{ label: '3', value: '3', isDisabled: true },
	{ label: '4', value: '4' }
	];

	$scope.submit = function() {
		alert('submit');
	};

	$scope.addItem = function() {
		var r = Math.ceil(Math.random() * 1000);
		$scope.radioData.push({ label: r, value: r });
	};

	$scope.removeItem = function() {
		$scope.radioData.pop();
	};

	// 校验身份证
	$scope.isCard = function(){
		var card = $("#card").value();
		console.log(card);
		var arrExp = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];//加权因子  
	    var arrValid = [1, 0, "X", 9, 8, 7, 6, 5, 4, 3, 2];//校验码  
	    if(/^/d{17}/d|x$/i.test(card)){  
	    	var sum = 0, idx;  
	    	for(var i = 0; i < strID.length - 1; i++){  
	            // 对前17位数字与权值乘积求和  
	            sum += parseInt(card.substr(i, 1), 10) * arrExp[i];  
	        }  
	        // 计算模（固定算法）  
	        idx = sum % 11;  
	        // 检验第18为是否与校验码相等  
	        var isture =  arrValid[idx] == card.substr(17, 1).toUpperCase();  
	        if(isture){
	        	console.log("正确 的身份证");
	        }else{
	        	console.log("不正确")
	        }
	        return 
	    }else{  
	    	console.log("输入正确的身份证");
	    	return false;  
	    }  
}



}])

.config(function($mdIconProvider) {
	$mdIconProvider.iconSet("avatars", 'icons/avatar-icons.svg',128);
});

;


	/**
	Copyright 2016 Google Inc. All Rights Reserved. 
	Use of this source code is governed by an MIT-style license that can be foundin the LICENSE file at http://material.angularjs.org/HEAD/license.
	**/

